﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DesignPatternStudy.Creations.Singletons
{
    class NestedSingleton
    {
        private NestedSingleton() { }

        public static NestedSingleton Singleton
        {
            get
            {
                return Nested._instance;
            }
        }

        public static void OtherStaticMethod()
        {
            Console.WriteLine("不会产生单例！");
        }

        private class Nested
        {
            public static readonly NestedSingleton _instance;

            static Nested()
            {
                _instance = new NestedSingleton();
            }
        }
    }
}
